#ifndef TRIANGLEWIDGET_H
#define TRIANGLEWIDGET_H


#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLBuffer>

#include <QApplication>
#include <QtOpenGLWidgets/QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QtOpenGL/QOpenGLTexture>
#include <QtOpenGL/QOpenGLShaderProgram>
#include <QtOpenGL/QOpenGLShader>

#include <QThread>
#include <mutex>

#include <opencv2/opencv.hpp>

namespace Ui {
class TriangleWidget;
}

class TriangleWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
    Q_OBJECT

public:
    explicit TriangleWidget(QOpenGLWidget *parent = 0);
    ~TriangleWidget();

    void ChangeWidget();

public:

    virtual void initializeGL();
    virtual void resizeGL(int w, int h);
    virtual void paintGL();
    std::vector<cv::Point2d> pointss;//
    std::vector<cv::Point2d> pointsss;
    int userValue ;



private:
    Ui::TriangleWidget *ui;
    int canvasSize;
    double scale;

    double L = 2.83;
    double w = 1.8;
    double D = 0.96;
    int a = 1901;
    int b = 659;
    cv::Mat MMatrix_back = (cv::Mat_<double>(3, 4) <<
                        -370.876, -481.99, -413.462, 1406010,
                    0.562965, -25.5681, -496.023, 475383,
                    -0.0153306, -0.764758, -0.644135, 1130.13);

private:
    QOpenGLShaderProgram* programShader;
    QOpenGLShaderProgram* programShader2;
    QOpenGLShaderProgram* programShader3;

    int posAttr;
    int texcoordLocation;
    int linelocation;
    int linelocation2;
    QOpenGLBuffer vbo;
    QOpenGLBuffer vbo1;
    QOpenGLBuffer vbo2;
    QOpenGLTexture* texture;

    std::mutex m_UserValueMutex;

    bool m_UpdateFlag;

};

#endif // TRIANGLEWIDGET_H
